home *** CD-ROM | disk | FTP | other *** search
/ Leonardo the Inventor / Leonardo The Inventor (93026)(Broderbund)(Riverdeep)(2004).iso / LEOWINMV / DATABASE.DIR / 00101_Script_IMPORT-EXPORT DATA < prev    next >
Text File  |  1996-03-28  |  2KB  |  57 lines

  1. -- --------------------------------------------------------------
  2. -- Handler importDBIndex imports the index of the database from
  3. -- the text file and stores it in cast members named according
  4. -- to the following convention, "A 1 INDEX", "B 1 INDEX" ...
  5.  
  6. on importDBIndex FirstCast
  7.   
  8.   repeat with letter = 65 to 90
  9.     set Filename = numToChar(letter) & ".TXT"
  10.     put  FileIO(mNew,"READ",the pathname & FileName) into FileObject
  11.     put fileObject(mReadToken,"","") into indexText
  12.     put findEmpty(cast FirstCast) into NextCast
  13.     put indexText after cast NextCast
  14.     set the name of cast NextCast to numToChar(letter) & " 1 INDEX"
  15.     fileObject(mDispose)
  16.   end repeat
  17.   
  18. end  
  19.  
  20. -- --------------------------------------------------------------
  21. -- Handler exportData puts the articles of the database back in
  22. -- a text file.
  23.  
  24. -- Example of use:
  25. -- put exportData (301, 369, "TITLE ") into datatext
  26. -- saveDataToFile datatext, "Bev:TEXT.TXT"
  27.  
  28. on exportData firstCast, lastCast, titleTag
  29.   set data = EMPTY
  30.   set oldTitle = EMPTY
  31.   
  32.   repeat with C = firstCast to lastCast
  33.     set title = the name of cast C
  34.     set title = char 1 to length(title) - 6 of title
  35.     
  36.     if NOT (title = oldTitle) then
  37.       -- title put twice, so searches can be done on words in the title too
  38.       put RETURN & titleTag & title & RETURN  & title & RETURN after data
  39.     end if
  40.     
  41.     put (the text of cast C) after data
  42.     put RETURN after data
  43.     set oldTitle = title
  44.   end repeat
  45.   return data
  46. end
  47.  
  48. -- --------------------------------------------------------------
  49. -- Handler saveDataToFile saves the given data in the given text
  50. -- file.
  51.  
  52. on saveDataToFile theData, fileName
  53.   put fileio (mNew, "WRITE", fileName) into FileObject
  54.   FileObject(mWriteString, theData)
  55.   FileObject(mDispose)
  56. end
  57.